function add1(x, y, z) {
  return x + y + z;
}

function add2(x, y, z) {
  x = x + 2;
  y = y * 2;
  z = z * z;
  return x + y + z;
}

function makeAdder(count) {
  count = count * count;

  return function (num) {
    return count + num;
  };
}

function log(date, type, message) {
  console.log(
    `[${date.getHours()}:${date.getMinutes()}][${type}]: [${message}]`
  );
}

function myCurrying(fn) {
  return function curried(...args) {
    if (args.length >= fn.length) {
      return fn.apply(this, args);
    } else {
      const curried2 = function (...args2) {
        return curried.apply(this, [...args, ...args2]);
      };
      return curried2;
    }
  };
}

var curryAdd = myCurrying(add1);

// console.log(curryAdd(10, 20, 30));
// console.log(curryAdd(10, 20)(30));
// console.log(curryAdd(10)(20)(30));

// function foo(x, y, z, m, n, a, b) {

// }
// console.log(foo.length)

function foo(x, y, z) {
  console.log(this);
  return x + y + z;
}

foo.call({}, 1, 2, 3);

var curryFoo = myCurrying(foo);
curryFoo.call(1, 1).call(2, 2).call("bbb", 3);
